package com.zb.user.controller;


import com.zb.result.PageUtil;
import com.zb.result.Result;
import com.zb.service.ZjUserAnnexService;
import com.zb.vo.UserAnnexVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * <p>
 * 用户附件表 前端控制器
 * </p>
 *
 * @author WEN
 * @since 2023-11-15
 */
@Api(tags = "用户附件类接口")
@RestController
@RequestMapping("/user/annex")
public class ZjUserAnnexController {

    @Resource
    private ZjUserAnnexService userAnnexService;

    @ApiOperation("新增或删除用户附件")
    @PostMapping("/save/{userId}")
    public Result save(@PathVariable @ApiParam(value = "客户ID", required = true) Long userId, @RequestBody @Valid UserAnnexVo userAnnexVo) {
        userAnnexService.save(userId, userAnnexVo);
        return Result.success("客户附件更新成功");
    }

    @ApiOperation("根据客户ID获取客户附件")
    @GetMapping("/getUserAnnex/{userId}")
    public Result getUserAnnex(@PathVariable @ApiParam(value = "客户ID", required = true) Long userId) {
        return Result.success("获取客户附件成功").data(PageUtil.row(userAnnexService.getUserAnnex(userId)));
    }

}
